package net.xiduth.game.player.dialogues.auto;

import net.xiduth.game.player.dialogues.Dialogue;

/**
 * 
 * @author Oracle
 * 
 * Handles voting rewards.
 *
 */
public class VoteRewards extends Dialogue {


	@Override
	public void start() {
		sendOptionsDialogue("Select an Option", "How many points do I have?", "I would like to exchange my points.", "How do I get points?", "I would like to access my bank account.", "Never mind.");
		stage = -1;
	}

	@Override
	public void run(int interfaceId, int option) {
		switch(stage) {
		case -1:
			sendOptionsDialogue("Select an Option", "How many points do I have?", "I would like to exchange my points.", "How do I get points?", "I would like to access my bank account.", "Never mind.");
			stage = 0;
			break;
		case 0:
			switch(option) {
			case OPTION_1:
				sendDialogue("You currently have " + player.getVotePoints() + " Vote points.");
				stage = -1;
				break;
			case OPTION_2:
				sendOptionsDialogue("Vote Rewards - Page 1", "Rune def. + Torso (5 pts.)", "Dragon def. + R.O.W (10 pts.)", "Fire cape (25 pts.)" , "PvP package + Gloves (1 pt.)", "Next page...");
				stage = 4;
				break;
			case OPTION_3:
				sendDialogue("You can ::vote for Xiduth every 12 hours for 1 point, and rewards.");
				stage = -1;
				break;
			case OPTION_4:
				player.getBank().openBank();
				player.getInterfaceManager().closeChatBoxInterface();
				break;
			case OPTION_5:
				player.getInterfaceManager().closeChatBoxInterface();
				break;
			}
			break;
		case 3:
			end();
			break;
		case 4:
			switch(option) {
		case OPTION_1:
				if (player.getVotePoints() >= 5) {
				player.getBank().addItem(8850, 1, true);
				player.getBank().addItem(10551, 1, true);
				player.setVotePoints(player.getVotePoints()
						- 5);
				player.getInterfaceManager().closeChatBoxInterface();
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 8850, 1);
				player.getPackets().sendIComponentText(1189, 4, "The items have been added to your bank.");
				stage = 3;
				}else{
				sendDialogue("You need 5 points to buy this item." );
				stage = 3;
				}
				break;
		case OPTION_2:
			if (player.getVotePoints() >= 10) {
			player.getBank().addItem(20072, 1, true);
			player.getBank().addItem(2572, 1, true);
			player.setVotePoints(player.getVotePoints()
					- 10);
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().sendChatBoxInterface(1189);
			player.getPackets().sendItemOnIComponent(1189, 1, 20072, 1);
			player.getPackets().sendIComponentText(1189, 4, "The item has been added to your bank.");
			stage = 3;
			}else{
			sendDialogue("You need 10 points to buy these items." );
			stage = 3;
			}
			break;
		case OPTION_3:
			if (player.getVotePoints() >= 25) {
			player.getBank().addItem(6570, 1, true);
			player.setVotePoints(player.getVotePoints()
					- 25);
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().sendChatBoxInterface(1189);
			player.getPackets().sendItemOnIComponent(1189, 1, 6570, 1);
			player.getPackets().sendIComponentText(1189, 4, "The item has been added to your bank.");
			stage = 3;
			}else{
			sendDialogue("You need 25 points to buy this item." );
			stage = 3;
			}
			break;
		case OPTION_4:
			if (player.getVotePoints() >= 1) {
			player.getBank().addItem(15332, 5, true);
			player.getBank().addItem(15272, 25, true);
			player.getBank().addItem(7462, 1, true);
			player.setVotePoints(player.getVotePoints()
					- 1);
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().sendChatBoxInterface(1189);
			player.getPackets().sendItemOnIComponent(1189, 1, 15332, 1);
			player.getPackets().sendIComponentText(1189, 4, "The items have been added to your bank.");
			stage = 3;
			}else{
			sendDialogue("You need 1 points to buy this item." );
			stage = 3;
			}
			break;
		case OPTION_5:
		end();
			player.getDialogueManager().startDialogue("VoteRewardsPage2");
			break;
		default:
			end();
			break;
		}}}

	@Override
	public void finish() {

	}

}
